package zhao.tx.eecs.common;


import android.app.AlertDialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.opengl.Visibility;
import android.os.Environment;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import zhao.tx.eecs.zhao.BookFrm;
import zhao.tx.eecs.zhao.MainFrm;
import zhao.tx.eecs.zhao.MapFrm;

/**
 * 继承此Activity类可以使用此类的方法
 * 该类是提供整个项目中Activity所使用到的公共方法
 * 该类中全属于公共方法.集成该类可以使用
 *
 * @author TanRuixiang
 * @Time 2011年7月25日 , PM 10:51:42
 */
public class CommonActivity extends ListActivity implements Runnable {
    /**
     * ==============BEGAN菜单导航栏管理(ItemId)================= *
     */
    public static String username = null;
    public static String role = null;
    public static String baseurl = "http://115.29.221.97/test/";
    public static String basepath = Environment.getExternalStorageDirectory () + "/QQBrowser/";
    public static boolean exit;
    public Intent intent = new Intent ();
    /**
     * ==============BEGAN进度条管理(ProgressDialog)=============*
     */
    public ProgressDialog progressDialog = null;
    public Handler handler = new Handler ();
    private int i = 0;
    /**==============END进度条管理(ProgressDialog)=============**/


    /**
     * ==============BEGAN底部菜单栏管理(ImageView)============*
     */
    public LinearLayout menu1 = null;
    public LinearLayout menu2 = null;
    public LinearLayout menu3 = null;
//	public View xhx1 = null ;
//	public View xhx2 = null ;
//	public View xhx3 = null ;

    /**
     * 菜单 工作列表 点击事件
     */
    public Menu1Touch view1 = new Menu1Touch ();
    /**
     * 菜单 上道点规划 点击事件
     */
    public Menu2Touch view2 = new Menu2Touch ();
    /**
     * 菜单 通讯录 点击事件
     */
    public Menu3Touch view3 = new Menu3Touch ();

    /**
     * ==============END底部菜单栏管理(ImageView)============*
     */

    public ListView listViewAll = null;
    public TextView textViewTitle = null;


    //工作列表 点击事件效果及处理设置
    class Menu1Touch implements OnTouchListener {
        //首页
        @Override
        public boolean onTouch ( View view, MotionEvent event ) {
            if ( event.getAction () == MotionEvent.ACTION_DOWN ) {
//				View xhx1=findViewById(R.id.xhx1);
//				View xhx2=findViewById(R.id.xhx2);
//				View xhx3=findViewById(R.id.xhx3);
//				if(xhx1.getVisibility()!=View.VISIBLE){
//					xhx1.setVisibility( View.VISIBLE);
//					xhx2.setVisibility(view.GONE);
//					xhx3.setVisibility(view.GONE);
                intent.setClass ( getApplicationContext (), MainFrm.class );
                startActivity ( intent );
                //}
            }
            return false;
        }
    }

    // 上道点规划 点击事件效果及处理设置
    class Menu2Touch implements OnTouchListener {
        //首页
        @Override
        public boolean onTouch ( View view, MotionEvent event ) {
            if ( event.getAction () == MotionEvent.ACTION_DOWN ) {
//				View xhx1=findViewById(R.id.xhx1);
//				View xhx2=findViewById(R.id.xhx2);
//				View xhx3=findViewById(R.id.xhx3);
                //if(xhx2.getVisibility()!=View.VISIBLE){
                //xhx2.setVisibility( View.VISIBLE);
                //xhx1.setVisibility(view.GONE);
                //xhx3.setVisibility(view.GONE);
                intent.setClass ( getApplicationContext (), MapFrm.class );
                startActivity ( intent );
                //}
            }

            return false;
        }
    }

    // 通讯录点击事件效果及处理设置
    class Menu3Touch implements OnTouchListener {
        //首页
        @Override
        public boolean onTouch ( View view, MotionEvent event ) {
            if ( event.getAction () == MotionEvent.ACTION_DOWN ) {
//				View xhx1=findViewById(R.id.xhx1);
//				View xhx2=findViewById(R.id.xhx2);
//				View xhx3=findViewById(R.id.xhx3);
//				if(xhx3.getVisibility()!=View.VISIBLE){
//					xhx3.setVisibility( View.VISIBLE);
//					xhx2.setVisibility(view.GONE);
//					xhx1.setVisibility(view.GONE);
                intent.setClass ( getApplicationContext (), BookFrm.class );
                startActivity ( intent );
                //}
            }
            return false;
        }
    }

    /**
     * 调用该CommonActivity类的线程
     */
    public void run () {

        try {
            Thread.sleep ( 50 );
        } catch ( InterruptedException e ) {
            e.printStackTrace ();
        }
        if ( i > 500 ) {
            progressDialog.dismiss ();
            handler.removeCallbacks ( this );
        } else {
            i = i + 10;
            handler.post ( this );
        }

    }
}